<?php

	eb_include_module_file("Core/ObjectModel");

	class UserModel extends ObjectModel
	{
		public function __construct()
		{
			parent::init('eb_user','Community/UserVO','us_id');
		}
		
		public function getColumns()
		{
			return array(
				new EbTableColumn('us_id','int',EB_PRIMARY_KEY,true,true),
				new EbTableColumn('ob_id','int',EB_INDEX_KEY),
				new EbTableColumn('email','varchar(64)'),
				new EbTableColumn('login','varchar(32)'),
				new EbTableColumn('password','varchar(128)'),
				new EbTableColumn('user_roles','varchar(128)')
			);
		}		
		
		public function insert($vo)
		{
			$vo->password = md5($vo->password);
			
			return parent::insert($vo);
		}
			
		
		public function selectByLoginAndPassword($login,$pwd)
		{
			$sql = 'SELECT * FROM eb_user WHERE login = \''.$login.'\' AND password = MD5(\''.$pwd.'\')';
			
			return $this->execute($sql);
		}
	}